
class CounterComponent extends React.Component {
    constructor() {
        super()
        this.state = {
            number: 0
        }
        this.reduce = this.reduce.bind(this)
        this.plus = this.plus.bind(this)
    }

    reduce() {
        this.setState({
            number: this.state.number-1
        })
    }

    plus() {
        this.setState({
            number: this.state.number+1
        })
    }

    render() {
        return (
            <div>
                <button onClick={this.reduce}>-</button>
                <p>{this.state.number}</p>
                <button onClick={this.plus}>+</button>
            </div>
        )
    }
}

let rootContainer = document.getElementById("root")
ReactDOM.render(
    <CounterComponent/>,
    rootContainer
)